﻿Class ProcessItemProgressObserver
    Implements Observer

    Private progressLabel As Label
    Private processItem As ProcessItem

    Sub New(ByRef aProgressLabel As Label, ByVal aProcessItem As ProcessItem)
        processItem = aProcessItem
        progressLabel = aProgressLabel
        registerToCommands()
        progressLabel.Text = getCommandsFinalizedDescription()
    End Sub

    Private Sub registerToCommands()
        For Each Command In processItem.getCommandList()
            Command.Register(Me)
        Next
    End Sub

    Sub Notify() Implements Observer.Notify
        progressLabel.Text = getCommandsFinalizedDescription()
    End Sub

    Private Function getCommandsFinalizedDescription() As String
        Return "(" + Convert.ToString(processItem.numberOfCompletedCommands()) + "/" + Convert.ToString(processItem.getCommandList().Count) + ")"
    End Function
End Class
